class UploaderController < ActionController::Base


  def upload
    upyun_bucket= ENV['upyun_bucket']
    image_path = params['Filename']
    upyun = Upyun::Rest.new(ENV['upyun_bucket'], ENV['upyun_username'], ENV['upyun_password'])

    file_path = "imgedemo/#{image_path}"
    upyun.put(file_path, params['fileToUpload'].to_io)
    render json: { image_url: "#{ENV['image_domain']}/#{file_path}" }.to_json
  end

  def upload_attachment
    file_path = params['Filename']
    upyun = Upyun::Rest.new(ENV['upyun_bucket'], ENV['upyun_username'], ENV['upyun_password'])

    file_path = "filedemo/#{file_path}"
    upyun.put(file_path, params['fileToUpload'].to_io)
    render json: { image_url: "#{ENV['image_domain']}/#{file_path}" }.to_json
  end

end
